package com.itita.ww2.handler.requesthandler.worldmap;

import java.sql.SQLException;

import com.itita.ww2.core.MessageHandler;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.game.user.UserService;
import com.itita.ww2.game.worldmap.WorldMapService;
import com.itita.ww2.model.area.AreaCityBattle;
import com.itita.ww2.model.user.UserProfile;
import com.itita.ww2.utils.handler.IRequestOper;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;

/**
 * 开战(攻打据点)
 * @author NorthLan
 *
 */
public class BaseBattleStart implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		UserProfile userProfile = UserService.getInstance().getUserProfile(user);
		int blockId = params.getInt("blockId");
		int cityId = params.getInt("cityId");
		int baseId = params.getInt("baseId");
		ISFSObject army = params.getSFSObject("army");

		// 暂时 退出city区域
		// 进入 战斗区域
		userProfile.setCurArea(new AreaCityBattle(blockId, cityId));

		// 开始攻打据点
		WorldMapService.attackBase(userProfile, army, blockId, cityId, baseId);

		MessageHandler.getInstance().sendMsg(requestCMD, null, user, null, true);
		return true;
	}

}
